// ignore_for_file: sized_box_for_whitespace, prefer_const_constructors

import 'package:dmz/base/pageWidget/base_stateful_widget.dart';
import 'package:dmz/business/home/controller/home_page_ctcs.dart';

import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:get/get.dart';

import '../../../base/widget/defult_widget.dart';

class HomePagecs extends BaseStatefulWidget<HomePageControllercs> {
  const HomePagecs({super.key});

  @override
  String titleString() => "首页";

  @override
  bool useLoadSir() => false;

  @override
  Widget buildContent(BuildContext context) {
    return Container(
        color: Colors.white,
        child: Column(children: [
          Row(mainAxisAlignment: MainAxisAlignment.spaceAround, children: [
            GestureDetector(
                onTap: () => controller.didBlueSan(),
                child: Container(height: 50, child: DefaultText('蓝牙扫描', 15))),
            GestureDetector(
                onTap: () => controller.login(),
                child: Container(height: 50, child: DefaultText('登录', 15)))
          ]),
          GestureDetector(
              onTap: () => controller.loginOut(),
              child: Container(height: 50, child: DefaultText('退出登录', 15))),
          Row(mainAxisAlignment: MainAxisAlignment.spaceAround, children: [
            GestureDetector(
                onTap: () => controller.sendBlueData(1),
                child: Container(height: 50, child: DefaultText('发送数据1', 15))),
            GestureDetector(
                onTap: () => controller.sendBlueData(2),
                child: Container(height: 50, child: DefaultText('发送数据2', 15)))
          ]),
          Obx(() => Column(children: [
                Container(child: DefaultText(controller.phone.value, 15)),
                Container(
                    color: Colors.red,
                    child:
                        DefaultText(controller.token.value, 15, maxLines: 3)),
              ])),
          Expanded(
              child: Obx(() => ListView.builder(
                  itemCount: controller.listData.length,
                  itemBuilder: (context, index) {
                    return Container(
                        padding: EdgeInsets.only(top: 20, left: 20, right: 20),
                        child: Row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            children: [
                              GestureDetector(
                                  onTap: () => controller
                                      .didQQ(controller.listData[index]),
                                  child: DefaultText(
                                      controller.listData[index].device.advName,
                                      15)),
                              GestureDetector(
                                  onTap: () => controller.checkBluetooth(
                                      controller.listData[index]),
                                  child: Obx(() => DefaultText(
                                      controller.contentNames.contains(
                                              controller.listData[index].device
                                                  .advName)
                                          ? '已连接'
                                          : '链接',
                                      15)))
                            ]));
                  }))),
        ]));
  }
}
